package com.pkx.guide.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pkx.guide.common.annotation.ORpose;
import com.pkx.guide.system.entity.TSysOperLog;
import com.pkx.guide.system.service.TSysOperLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 操作日志记录 控制器
 *
 * @author sunsy
 * @since 2022-01-21
 */
@RestController
@RequestMapping("/system/operLog")
@Tag(name = "操作日志记录")
@Slf4j
@ORpose
public class TSysOperLogController {

    @Autowired
    private TSysOperLogService tSysOperLogService;

    @Operation(summary = "操作日志记录分页列表")
    @GetMapping("/page")
    public IPage<TSysOperLog> page(Page page, TSysOperLog tSysOperLog) {
        return tSysOperLogService.pageList(page,tSysOperLog);
    }

    @Operation(summary = "操作日志记录列表")
    @GetMapping("/list")
    public List<TSysOperLog> list(TSysOperLog tSysOperLog) {
        return tSysOperLogService.listByEntity(tSysOperLog);
    }

    @Operation(summary = "操作日志记录详情")
    @GetMapping(value = "/{id}")
    public TSysOperLog selectById(@PathVariable("id") Integer id) {
        return tSysOperLogService.selectById(id);
    }

    @Operation(summary = "操作日志记录新增")
    @PostMapping("/")
    public Boolean add(@RequestBody TSysOperLog tSysOperLog) {
        return tSysOperLogService.saveTSysOperLog(tSysOperLog);
    }

    @Operation(summary = "操作日志记录修改")
    @PutMapping("/")
    public Boolean modify(@RequestBody TSysOperLog tSysOperLog) {
        return tSysOperLogService.modify(tSysOperLog);
    }

    @Operation(summary = "操作日志记录删除(单个条目)")
    @DeleteMapping(value = "/{id}")
    public Boolean deleteById(@PathVariable("id") Integer id) {
        return tSysOperLogService.deleteById(id);
    }

    @Operation(summary = "操作日志记录删除(批量)")
    @DeleteMapping(value = "/batchDeleteByIds/{ids}")
    public Boolean batchDeleteByIds(@PathVariable("ids") String ids) {
        return tSysOperLogService.batchDeleteByIds(ids);
    }
}
